﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace DevPhoneToolkitSample
{
    public partial class MenuItems : UserControl
    {
        public MenuItems()
        {
            InitializeComponent();
        }

        public event EventHandler<EventArgs> ClickItem;

        public void OnClickItem(EventArgs e)
        {
            var handler = ClickItem;
            if (handler != null) handler(this, e);
        }


        public static readonly DependencyProperty HeaderProperty =
            DependencyProperty.Register("Header", typeof(string), typeof(MenuItems), new PropertyMetadata(default(string)));

        public string Header
        {
            get { return (string)GetValue(HeaderProperty); }
            set
            {
                SetValue(HeaderProperty, value);
                TxtHeader.Text = value;
            }
        }

        public static readonly DependencyProperty DescriptionProperty =
            DependencyProperty.Register("Description", typeof(string), typeof(MenuItems), new PropertyMetadata(default(string)));

        public string Description
        {
            get { return (string)GetValue(DescriptionProperty); }
            set
            {
                SetValue(DescriptionProperty, value);
                TxtDescription.Text = value;
            }
        }

        public static readonly DependencyProperty ShowNewProperty =
            DependencyProperty.Register("ShowNew", typeof(bool), typeof(MenuItems), new PropertyMetadata(false));

        public bool ShowNew
        {
            get { return (bool)GetValue(ShowNewProperty); }
            set
            {
                SetValue(ShowNewProperty, value);
                NewIco.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
            }

        }

        public static readonly DependencyProperty ShowUpdateProperty =
            DependencyProperty.Register("ShowUpdate", typeof(bool), typeof(MenuItems), new PropertyMetadata(false));

        public bool ShowUpdate
        {
            get { return (bool)GetValue(ShowUpdateProperty); }
            set
            {
                SetValue(ShowUpdateProperty, value);
                UpdIco.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
            }

        }

        public static readonly DependencyProperty ShowMvvmProperty =
            DependencyProperty.Register("ShowMvvm", typeof(bool), typeof(MenuItems), new PropertyMetadata(false));

        public bool ShowMvvm
        {
            get { return (bool)GetValue(ShowMvvmProperty); }
            set
            {
                SetValue(ShowMvvmProperty, value);
                MvvmIco.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
            }

        }

        public static readonly DependencyProperty ShowSlTkProperty =
            DependencyProperty.Register("ShowSlTk", typeof(bool), typeof(MenuItems), new PropertyMetadata(false));

        public bool ShowSlTk
        {
            get { return (bool)GetValue(ShowSlTkProperty); }
            set
            {
                SetValue(ShowSlTkProperty, value);
                SlTkIco.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
            }

        }

        public static readonly DependencyProperty ImageControlProperty =
            DependencyProperty.Register("ImageControl", typeof(ImageSource), typeof(MenuItems), new PropertyMetadata(default(ImageSource)));

        public ImageSource ImageControl
        {
            get { return (ImageSource)GetValue(ImageControlProperty); }
            set
            {
                SetValue(ImageControlProperty, value);
                ImgControl.Source = value;
            }
        }

        public static readonly DependencyProperty ImageBandProperty =
                DependencyProperty.Register("ImageBand", typeof(ImageSource), typeof(MenuItems), new PropertyMetadata(default(ImageSource)));

        public ImageSource ImageBand
        {
            get { return (ImageSource)GetValue(ImageBandProperty); }
            set
            {
                SetValue(ImageBandProperty, value);
                ImgBand.Source = value;
            }
        }

        private void LayoutRootTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            OnClickItem(new EventArgs());
        }

    }
}
